<?php
class Mail extends CI_Controller {
	public function __construct() {
		parent::__construct ();
		// 登录校验
		$this->common->check_login_mobile ();
		$this->load->helper ( array (
				'form',
				'url' 
		) );
	}
	
	// 留言
	public function index() {
		$this->load->model ( 'message_model' );
		$data ['result'] = $this->message_model->message_list ( false, $_SESSION ['mobile'] ['id'] );
		
		$data ['left'] = $this->load->view ( 'mobile/left', '', TRUE );
		$data ['foot'] = $this->load->view ( 'mobile/foot', '', TRUE );
		
		$this->load->view ( 'mobile/mail', $data );
	}
	
	// 留言
	public function message() {
		$this->load->model ( 'message_model' );
		$result = $this->message_model->message_insert ( $_SESSION ['mobile'] ['id'] );
		
		if ($result) {
			exit ( $this->common->alert_msg_url ( '留言成功', site_url ( 'mobile/mail' ) ) );
		} else {
			exit ( $this->common->alert_msg_goback ( '留言失败' ) );
		}
	}
}